package com.road.yishi.dao.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.road.entity.QuestCondiction;
import com.road.yishi.dao.QuestCondictionDao;
import com.road.yishi.db.StrategyBaseDao;

@Repository
public class QuestCondictionDaoImpl extends StrategyBaseDao implements QuestCondictionDao {

	@Override
	public List<QuestCondiction> getQuestCondictions() {
		String sqlText = "select * from t_s_questcondiction;";
		PreparedStatement pstmt = execQuery(sqlText);
		ResultSet rs = null;
		List<QuestCondiction> infos = null;
		if (pstmt != null) {
			infos = new ArrayList<QuestCondiction>();
			try {
				rs = pstmt.executeQuery();
				while (rs.next()) {
					QuestCondiction info = new QuestCondiction();
					info.setTemplateId(rs.getInt("TemplateId"));
					info.setCondictionId(rs.getInt("CondictionId"));
					info.setCondictionType(rs.getInt("CondictionType"));
					info.setCondictionTitle(rs.getString("CondictionTitle"));
					info.setPara1(rs.getString("Para1"));
					info.setPara2(rs.getInt("Para2"));
					info.setPara3(rs.getInt("Para3"));
					//info.setPara4(rs.getString("Para4"));
					infos.add(info);
				}
			} catch (SQLException e) {
				infos = null;
				Log.error("执行出错" + sqlText, e);
			} finally {
				closeConn(pstmt, rs);
			}
		}
		return infos;
	}
}
